<template>
	<div>
		<div style="width: 100%;height: 100px;">
			<a-form formLayout="horizontal" :label-col="{ span: 5 }" :wrapper-col="{ span: 18 }">
				<a-row :gutter="[16, 8]">
					<!--          <a-col :span="4">-->
					<!--            <a-button-group >-->
					<!--              <a-button @click="whole()">-->
					<!--                全部-->
					<!--              </a-button>-->
					<!--              <a-button @click="classA()">-->
					<!--                甲班-->
					<!--              </a-button>-->
					<!--              <a-button @click="classB()">-->
					<!--                乙班-->
					<!--              </a-button>-->
					<!--              <a-button @click="classC()">-->
					<!--                丙班-->
					<!--              </a-button>-->
					<!--            </a-button-group>
					-->
					<!--          </a-col>-->
					<a-col :span="4">
						<a-space>
							<a-button icon="left" @click.stop="goPrev" />
							<a-date-picker v-model:value="currentMonth" placeholder="选择日期" :allowClear="false"
								@change="onChangeDate" />
							<a-button icon="right" @click.stop="goNext" />
						</a-space>
					</a-col>
					<a-col :span="4">
						<a-form-model-item label="姓名" prop="realname">
							<a-input v-model="queryParam.realname" placeholder="请输入姓名" />
						</a-form-model-item>
					</a-col>
					<a-col :span="4">
						<!--            <a-form-model-item label="公司" prop="company">-->
						<!--              <j-dict-select-tag-->
						<!--                dictCode="crm_company,name,id"-->
						<!--                v-model="queryParam.company"-->
						<!--                placeholder="请选择组织"-->
						<!--              >-->
						<!--              </j-dict-select-tag>-->
						<!--            </a-form-model-item>-->
						<a-form-model-item label="工号" prop="workNo">
							<a-input v-model="queryParam.workNo" placeholder="请输入工号" />
						</a-form-model-item>
					</a-col>
					<a-col :span="4">
						<a-form-model-item label="车间" prop="workshop">
							<j-multi-select-tag placeholder="请选择车间" v-model="queryParam.workshop" dictCode="workshop" />
						</a-form-model-item>
					</a-col>
					<a-col :span="4">
						<a-form-model-item label="班次" prop="classes">
							<j-dict-select-tag placeholder="请选择班次" v-model="queryParam.classes" dictCode="shift" />
						</a-form-model-item>
					</a-col>
					<a-col :span="4">
						<a-form-model-item label="品种" prop="productType">
							<j-dict-select-tag placeholder="请选择" v-model="queryParam.productType"
								dictCode="crm_product_type_spooling,product_type,id" />
						</a-form-model-item>
					</a-col>
				</a-row>
			</a-form>
			<a-row :gutter="16">
				<a-col :span="24">
					<a-space style="float: right">
						<a-button @click="handleExportXls('自络')" type="default" icon="export">导出报表</a-button>
						<a-button @click="handleSearch()" type="primary">
							搜索
						</a-button>
						<a-button @click="handleAdd" type="primary">新增</a-button>
						<a-button @click="generateSalary()" type="primary">
							生成报表
						</a-button>
						<!-- <a-button>导出长度报表</a-button> -->
						<!-- <a-button>导出报表</a-button> -->
					</a-space>
				</a-col>
			</a-row>
		</div>
		<div style="margin-top: 30px;">
			<a-table :columns="columns" rowKey="id" :data-source="dataSource" :scroll="{ x: 6500 }"
				:pagination="ipagination" :loading="loading"
				:rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
				@change="handleTableChange">
				<!-- 操作 -->
				<a-space slot="action" slot-scope="text, record">
					<template>
						<a-button style="padding: 0px" type="link" icon="edit" @click="handleEdit(record)">编辑</a-button>
						<a-popconfirm title="确认要删除吗?" @confirm="() => handleDelete(record.id)">
							<a-button style="color: red; padding: 0px" type="link" icon="delete">删除</a-button>
						</a-popconfirm>
					</template>
				</a-space>
			</a-table>
		</div>

		<dang-che-gong-modal ref="modalForm" @ok="modalFormOk" :planTime="queryParam.planTime"></dang-che-gong-modal>
	</div>
</template>

<script>
	import {
		JeecgListMixin
	} from '@/mixins/JeecgListMixin'
	import DangCheGongModal from './modules/DangCheGongModal'
	import moment from 'moment'
	import {
		getGenerateSalarySpooling
	} from '../../../api/customApi'
	const path = '/crm_salary_excel_spooling/crmSalaryExcelSpooling'
	export default {
		mixins: [JeecgListMixin],
		components: {
			DangCheGongModal
		},
		data() {
			return {
				currentMonth: moment(),
				columns,
				queryParam: {
					planTime: moment().format('YYYY-MM-DD')
				},
				url: {
					list: path + '/list',
					delete: path + '/delete',
					deleteBatch: path + '/deleteBatch',
					exportXlsUrl: '/crm_salary_excel_spooling/crmSalaryExcelSpooling/exportExcel'
				}
			}
		},
		methods: {
			goPrev() {
				var newMonth = moment(this.currentMonth).subtract(1, 'day')
				this.currentMonth = newMonth
				this.queryParam.planTime = this.currentMonth.format('YYYY-MM-DD')
				this.searchQuery()
			},
			goNext() {
				var newMonth = moment(this.currentMonth).add(1, 'day')
				this.currentMonth = newMonth
				this.queryParam.planTime = this.currentMonth.format('YYYY-MM-DD')
				this.searchQuery()
			},
			onChangeDate(date, dateString) {
				this.queryParam.planTime = dateString
				this.searchQuery()
			},
			changeObject() {},
			refresh() {
				this.searchQuery()
			},
			handleSearch() {
				this.searchQuery()
				this.visible = false
			},
			handleCancel() {
				this.visible = false
			},
			handleReset() {
				this.searchReset()
			},
			add() {
				this.visable1 = true
			},
			detail(record) {},
			onChangePage(e) {
				this.ipagination.current = e
				this.loadData()
			},
			generateSalary() {
				let query = {
					planTime: this.queryParam.planTime
				}
				getGenerateSalarySpooling(query).then(res => {
					if (res.success) {
						this.$message.success('生成成功')
						this.searchQuery()
					}
				})
			},
			btnImport() {},
			btnExport() {}
		}
	}

	const columns = [{
			title: '日期',
			width: 150,
			dataIndex: 'planTime',
			key: 'planTime',
			fixed: 'left'
		},
		{
			title: '车间',
			width: 100,
			dataIndex: 'workshop',
			key: 'workshop',
			fixed: 'left'
		},
		{
			title: '班次',
			width: 100,
			dataIndex: 'shift_dictText',
			key: 'shift',
			fixed: 'left'
		},
		{
			title: '上班时间',
			width: 100,
			dataIndex: 'workHours',
			key: 'workHours',
			fixed: 'left'
		},
		{
			title: '机台时间',
			width: 100,
			dataIndex: 'machineHours',
			key: 'machineHours',
			fixed: 'left'
		},
		{
			title: '机号',
			dataIndex: 'deviceNo',
			key: 'deviceNo',
			width: 150
		},
		{
			title: '工号',
			dataIndex: 'workNo',
			key: 'workNo',
			width: 150
		},
		{
			title: '姓名',
			dataIndex: 'realname',
			key: 'realname',
			width: 150
		},
		{
			title: '型号',
			dataIndex: 'column8',
			key: 'column8',
			width: 150
		},
		{
			title: '机台分类（自络、托盘）',
			dataIndex: 'column9',
			key: 'column9',
			width: 200
		},
		{
			title: '品种类别',
			dataIndex: 'productCategory',
			key: 'productCategory',
			width: 150
		},
		{
			title: '品种',
			dataIndex: 'productType_dictText',
			key: 'productType_dictText',
			width: 150
		},
		{
			title: '支数',
			dataIndex: 'productBranch',
			key: 'productBranch',
			width: 150
		},
		{
			title: '机台系数',
			dataIndex: 'machineCoefficient',
			key: 'machineCoefficient',
			width: 150
		},
		{
			title: '品种系数',
			dataIndex: 'productTypeCoefficient',
			key: 'productTypeCoefficient',
			width: 150
		},
		{
			title: '单价系数',
			dataIndex: 'unitPriceCoefficient',
			key: 'unitPriceCoefficient',
			width: 150
		},
		{
			title: '综合系数',
			dataIndex: 'comprehensiveCoefficient',
			key: 'comprehensiveCoefficient',
			width: 150
		},
		{
			title: '锭数',
			dataIndex: 'ingots',
			key: 'ingots',
			width: 150
		},
		{
			title: '8小时定额产量',
			dataIndex: 'fixedOutputEightHours',
			key: 'fixedOutputEightHours',
			width: 150
		},
		{
			title: '台数',
			dataIndex: 'machinesNum',
			key: 'machinesNum',
			width: 150
		},
		{
			title: '台数（8小时）',
			dataIndex: 'machinesNumEightHours',
			key: 'machinesNumEightHours',
			width: 150
		},
		{
			title: '定额看台（台）',
			dataIndex: 'fixedMachinesNum',
			key: 'fixedMachinesNum',
			width: 150
		},
		{
			title: '总看台率%',
			dataIndex: 'totalMachinesRate',
			key: 'totalMachinesRate',
			width: 150
		},
		{
			title: '机台产量（kg/台）',
			dataIndex: 'machinesOutput',
			key: 'machinesOutput',
			width: 200
		},
		{
			title: '工资产量 （kg/台）',
			dataIndex: 'wagesOutput',
			key: 'wagesOutput',
			width: 200
		},
		{
			title: '扩台',
			dataIndex: 'expansionMachines',
			key: 'expansionMachines',
			width: 150
		},
		{
			title: '换管盒数量',
			dataIndex: 'changeTubeBoxNum',
			key: 'changeTubeBoxNum',
			width: 150
		},
		{
			title: '换管盒数星(8小时)',
			dataIndex: 'changeTubeBoxNumEightHours',
			key: 'changeTubeBoxNumEightHours',
			width: 200
		},
		{
			title: '产量单价（kg/台）',
			dataIndex: 'outputPrice',
			key: 'outputPrice',
			width: 200
		},
		{
			title: '换管盒单价',
			dataIndex: 'changeTubeBoxPrice',
			key: 'changeTubeBoxPrice',
			width: 150
		},
		{
			title: '换管盒工资',
			dataIndex: 'changeTubeBoxWages',
			key: 'changeTubeBoxWages',
			width: 150
		},
		{
			title: '产量工资（元/台）',
			dataIndex: 'outputWages',
			key: 'outputWages',
			width: 200
		},
		{
			title: '锭数补贴（元/台）',
			dataIndex: 'ingotsNumSubsidies',
			key: 'ingotsNumSubsidies',
			width: 200
		},
		{
			title: '系数补扣',
			dataIndex: 'coefficientDeduction',
			key: 'coefficientDeduction',
			width: 150
		},
		{
			title: '其它补贴',
			dataIndex: 'otherSubsidies',
			key: 'otherSubsidies',
			width: 150
		},
		{
			title: '合计工资',
			dataIndex: 'totalWages',
			key: 'totalWages',
			width: 150
		},
		{
			title: '完成率%',
			dataIndex: 'completionRate',
			key: 'completionRate',
			width: 150
		},
		{
			title: '机台保养',
			dataIndex: 'machinesMaintenance',
			key: 'machinesMaintenance',
			width: 150
		},
		{
			title: '备注',
			dataIndex: 'remark',
			key: 'remark',
			width: 150
		},
		{
			title: '单台看台率',
			dataIndex: 'selfSpoolingFixedMachinesRate',
			key: 'selfSpoolingFixedMachinesRate',
			width: 150
		},
		{
			title: '上班时间',
			dataIndex: 'workingTime',
			key: 'workingTime',
			width: 150
		},
		{
			title: '看台',
			dataIndex: 'manageMachines',
			key: 'manageMachines',
			width: 150
		},
		{
			title: '台车时间',
			dataIndex: 'machinesCarTime',
			key: 'machinesCarTime',
			width: 150
		},
		{
			title: '台车天时间',
			dataIndex: 'machinesCarDayTime',
			key: 'machinesCarDayTime',
			width: 150
		},
		{
			title: '工号转换',
			dataIndex: 'workIdConversion',
			key: 'workIdConversion',
			width: 150
		},
		{
			title: '原单价',
			dataIndex: 'originalPrice',
			key: 'originalPrice',
			width: 150
		},
		{
			title: '原工资',
			dataIndex: 'originalWages',
			key: 'originalWages',
			width: 150
		},
		{
			title: '现-原',
			dataIndex: 'originalNow',
			key: 'originalNow',
			width: 150
		},
		{
			title: '幅度',
			dataIndex: 'rangeData',
			key: 'rangeData',
			width: 150
		},
		{
			title: '操作',
			dataIndex: 'action',
			align: 'center',
			scopedSlots: {
				customRender: 'action'
			},
			fixed: 'right'
		}
	]
</script>

<style scoped></style>